package main
import "fmt"

func main(){
    /*
	练习4：验证用户名密码是否正确
		var userList = map[string]map[string]string{
			"root":{"password":"123456", "tel":"158xxxxxxxx"},
			"admin":{"password":"123456", "tel":"158xxxxxxxx"},
			"xiaoming":{"password":"123456", "tel":"158xxxxxxxx"}}
		输入用户名密码，进行验证，验证成功后，输出手机号码
	*/
	userList := map[string]map[string]string{
		"root": {"password": "123456", "tel": "158xxxxxxxx"},
		"admin": {"password": "123456", "tel": "158xxxxxxxx"},
		"xiaoming": {"password": "123456", "tel": "158xxxxxxxx"},
	}
	
	var username string
	var password string
	
	fmt.Println("请输入用户名: ")
	fmt.Scan(&username)
	
	fmt.Println("请输入密码: ")
	fmt.Scan(&password)
	
	if user, ok := userList[username]; ok {
		if user["password"] == password {
			fmt.Println("手机号码:", user["tel"])
		} else {
			fmt.Println("密码错误")
		}
	} else {
		fmt.Println("用户名不存在")
	}

}
